Fixed consoled race condition.
authorcl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Tue, 13 Sep 2005 10:13:52 +0000 (10:13 +0000)
committercl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Tue, 13 Sep 2005 10:13:52 +0000 (10:13 +0000)
Signed-off by: Andy Peace <andrew.peace@xensource.com>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
tools/console/daemon/io.c

index 08aeda1c468c79e15b12ee44086537ff277c1f31..2fead094b031ffded0f64b4588df98f1afebb9f0 100644 (file)
@@ -87,6 +87,7 @@ static void buffer_append(struct domain *dom)
        struct buffer *buffer = &dom->buffer;
        struct ring_head *ring = (struct ring_head *)dom->page;
        size_t size;
+       u32 oldcons;
 
        while ((size = ring->prod - ring->cons) != 0) {
                if ((buffer->capacity - buffer->size) < size) {
@@ -98,7 +99,8 @@ static void buffer_append(struct domain *dom)
                        }
                }
 
-               while (ring->cons < ring->prod) {
+               oldcons = ring->cons;
+               while (ring->cons < (oldcons + size)) {
                        buffer->data[buffer->size] =
                                ring->buf[XENCONS_IDX(ring->cons)];
                        buffer->size++;